<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>购物数量</title>
		<script type="text/javascript">
			window.onload=function(){
				var mybtn1=document.getElementById("btn1");
				var mytxtShuru=document.getElementById("txtShuru");
				var mybtn2=document.getElementById("btn2");
				var a=1;
				
				mybtn1.onclick=function(){
					//console.log( typeof mytxtShuru.value); 测试得出输入框的值为string类型
					if(a>1){
						a--;
						mytxtShuru.value=a;
					}
					console.log(a);
				}
				mybtn2.onclick=function(){
					a++;
					mytxtShuru.value=a;
					console.log(a);
				}
			}
		</script>
	</head>
	<body>
		<input type="button" value="-" id="btn1"/>
		<input type="text" value="1" id="txtShuru"/>
		<input type="button" value="+" id="btn2"/>
	</body>
</html>
